<template>
	<wsPage title="订单信息">
		<div slot="page_operate">
			<Button type="ghost" @click="refresh"><Icon type="refresh"></Icon><span>刷新</span></Button>
		</div>
		<Row class="tab-demo">
			<Col span="24">
				<Button :type="activeIndex == 0 ? 'primary' : 'ghost'" @click="order(0)">全部订单(<span class="ws-text-red" v-text="queryForm.stat.s0"></span>)</Button>
				<Button :type="activeIndex == 1 ? 'primary' : 'ghost'" @click="order(1)">待付款(<span class="ws-text-red" v-text="queryForm.stat.s1"></span>)</Button>
				<Button :type="activeIndex == 7 ? 'primary' : 'ghost'" @click="order(7)">待接单(<span class="ws-text-red" v-text="queryForm.stat.s7"></span>)</Button>
				<Button :type="activeIndex == 2 ? 'primary' : 'ghost'" @click="order(2)">待发货(<span class="ws-text-red" v-text="queryForm.stat.s2"></span>)</Button>
				<Button :type="activeIndex == 3 ? 'primary' : 'ghost'" @click="order(3)">已发货(<span class="ws-text-red" v-text="queryForm.stat.s3"></span>)</Button>

				<Button :type="activeIndex == 4 ? 'primary' : 'ghost'" @click="order(4)">已完成(<span class="ws-text-red" v-text="queryForm.stat.s4"></span>)</Button>
				<Button :type="activeIndex == 6 ? 'primary' : 'ghost'" @click="order(6)">已关闭(<span class="ws-text-red" v-text="queryForm.stat.s6"></span>)</Button>
			</Col>
		</Row>
		<!-- 全部订单列表 -->
		<wsSmPanel :page="allTable.allPage" @simple-query="query" @page-change="query" v-show="this.activeIndex == 0">
			<div slot="query_form">
				<Form :model="queryForm" :label-width="100" inline>
					<FormItem label="订单编号">
						<Input v-model="queryForm.sn" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="买家手机号">
						<Input v-model="queryForm.memberName" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="买家昵称">
						<Input v-model="queryForm.nickname" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="收货人姓名">
						<Input v-model="queryForm.consignee" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="收货人手机号">
						<Input v-model="queryForm.phone" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="时间区间">
						<Row>
			                <Col span="11">
			                    <FormItem>
			                        <DatePicker type="date" placeholder="查询开始时间" v-model="queryForm.searchStartTime" @on-change="dateConfirm"></DatePicker>
			                    </FormItem>
			                </Col>
			                <Col span="2" style="text-align: center">-</Col>
			                <Col span="11">
			                    <FormItem>
			                        <DatePicker type="date" placeholder="查询结束时间" v-model="queryForm.searchEndTime" @on-change="dateConfirm"></DatePicker>
			                    </FormItem>
			                </Col>
			            </Row>      
			        </FormItem>
				</Form>
			</div>
			<div slot="list_data">
				<ws-table :data="allTable.allData" style="width: 100%">
					<ws-table-column align="center" type="selection" width="80" fixed="left"></ws-table-column>v
					<ws-table-column align="center" prop="sn" label="订单编号" width="160" fixed="left"></ws-table-column>
					<ws-table-column align="center" label="会员信息" width="160">
						<template slot-scope="scope">
							<p><span v-text="scope.row.nickname"></span></p>
							<p><span v-text="scope.row.memberName"></span></p>
						</template>
					</ws-table-column>
					<ws-table-column align="center" prop="consumeAmount" label="订单金额" width="80"></ws-table-column>
					<ws-table-column align="center" prop="payAmount" label="实际支付金额" width="120"></ws-table-column>
					<ws-table-column align="center" label="收件人信息" width="160">
						<template slot-scope="scope">
							<p><span v-text="scope.row.consignee"></span></p>
							<p><span v-text="scope.row.phone"></span></p>
						</template>
					</ws-table-column>
					<ws-table-column align="center" prop="fullAddress" label="收件人地址" min-width="200">
					</ws-table-column>
					<ws-table-column align="center" prop="createDate" label="创建时间" width="160"></ws-table-column>
					<ws-table-column align="center" label="订单状态" width="100" fixed="right">
						<template slot-scope="scope">
							<p><span v-text="scope.row.consignee"></span></p>
							<p><span v-text="scope.row.phone"></span></p>
						</template>
					</ws-table-column>
					<ws-table-column align="center" label="操作" width="100" fixed="right">
						<template slot-scope="scope">
							<Button @click="jumpDetail(scope.row.id,scope.row.refundId)" type="text" size="small">详情</Button>
						</template>
					</ws-table-column>
				</ws-table>
			</div>
		</wsSmPanel>

		<!-- 待付款列表 -->
		<wsSmPanel :page="toPayTable.toPayPage" @simple-query="query" @page-change="query" v-show="this.activeIndex == 1">
			<div slot="query_form">
				<Form :model="queryForm" :label-width="100" inline>
					<FormItem label="订单编号">
						<Input v-model="queryForm.sn" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="买家手机号">
						<Input v-model="queryForm.memberName" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="买家昵称">
						<Input v-model="queryForm.nickname" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="收货人姓名">
						<Input v-model="queryForm.consignee" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="收货人手机号">
						<Input v-model="queryForm.phone" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="时间区间">
						<Row>
			                <Col span="11">
			                    <FormItem>
			                        <DatePicker type="date" placeholder="查询开始时间" v-model="queryForm.searchStartTime" @on-change="dateConfirm"></DatePicker>
			                    </FormItem>
			                </Col>
			                <Col span="2" style="text-align: center">-</Col>
			                <Col span="11">
			                    <FormItem>
			                        <DatePicker type="date" placeholder="查询结束时间" v-model="queryForm.searchEndTime" @on-change="dateConfirm"></DatePicker>
			                    </FormItem>
			                </Col>
			            </Row>      
			        </FormItem>
				</Form>
			</div>
			<div slot="list_data">
				<Table border :columns="toPayTable.toPayColumns" :data="toPayTable.toPayData"></Table>
			</div>
		</wsSmPanel>

		<!-- 待接单列表 -->
		<wsSmPanel :page="toPayTable.toPayPage" @simple-query="query" @page-change="query" v-show="this.activeIndex == 7">
			<div slot="query_form">
				<Form :model="queryForm" :label-width="100" inline>
					<FormItem label="订单编号">
						<Input v-model="queryForm.sn" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="买家手机号">
						<Input v-model="queryForm.memberName" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="买家昵称">
						<Input v-model="queryForm.nickname" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="收货人姓名">
						<Input v-model="queryForm.consignee" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="收货人手机号">
						<Input v-model="queryForm.phone" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="时间区间">
						<Row>
			                <Col span="11">
			                    <FormItem>
			                        <DatePicker type="date" placeholder="查询开始时间" v-model="queryForm.searchStartTime" @on-change="dateConfirm"></DatePicker>
			                    </FormItem>
			                </Col>
			                <Col span="2" style="text-align: center">-</Col>
			                <Col span="11">
			                    <FormItem>
			                        <DatePicker type="date" placeholder="查询结束时间" v-model="queryForm.searchEndTime" @on-change="dateConfirm"></DatePicker>
			                    </FormItem>
			                </Col>
			            </Row>      
			        </FormItem>
				</Form>
			</div>
			<div slot="list_data">
				<Table border :columns="toReceiveOrderTable.toReceiveColumns" :data="toReceiveOrderTable.toReceiveOrderData"></Table>
			</div>
		</wsSmPanel>

		<!-- 待发货列表 -->
		<wsSmPanel :page="shippingTable.shippingPage" @simple-query="query" @page-change="query" v-show="this.activeIndex == 2">
			<div slot="query_form">
				<Form :model="queryForm" :label-width="100" inline>
					<FormItem label="订单编号">
						<Input v-model="queryForm.sn" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="买家手机号">
						<Input v-model="queryForm.memberName" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="买家昵称">
						<Input v-model="queryForm.nickname" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="收货人姓名">
						<Input v-model="queryForm.consignee" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="收货人手机号">
						<Input v-model="queryForm.phone" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="时间区间">
						<Row>
			                <Col span="11">
			                    <FormItem>
			                        <DatePicker type="date" placeholder="查询开始时间" v-model="queryForm.searchStartTime" @on-change="dateConfirm"></DatePicker>
			                    </FormItem>
			                </Col>
			                <Col span="2" style="text-align: center">-</Col>
			                <Col span="11">
			                    <FormItem>
			                        <DatePicker type="date" placeholder="查询结束时间" v-model="queryForm.searchEndTime" @on-change="dateConfirm"></DatePicker>
			                    </FormItem>
			                </Col>
			            </Row>      
			        </FormItem>
				</Form>
			</div>
			<div slot="list_data">
				<Table border :columns="shippingTable.shippingColumns" :data="shippingTable.shippingData"></Table>
			</div>
		</wsSmPanel>

		<!-- 已发货列表 -->
		<wsSmPanel :page="deliveryTable.deliveryPage" @simple-query="query" @page-change="query" v-show="this.activeIndex == 3">
			<div slot="query_form">
				<Form :model="queryForm" :label-width="100" inline>
					<FormItem label="订单编号">
						<Input v-model="queryForm.sn" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="买家手机号">
						<Input v-model="queryForm.memberName" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="买家昵称">
						<Input v-model="queryForm.nickname" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="收货人姓名">
						<Input v-model="queryForm.consignee" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="收货人手机号">
						<Input v-model="queryForm.phone" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="时间区间">
						<Row>
			                <Col span="11">
			                    <FormItem>
			                        <DatePicker type="date" placeholder="查询开始时间" v-model="queryForm.searchStartTime" @on-change="dateConfirm"></DatePicker>
			                    </FormItem>
			                </Col>
			                <Col span="2" style="text-align: center">-</Col>
			                <Col span="11">
			                    <FormItem>
			                        <DatePicker type="date" placeholder="查询结束时间" v-model="queryForm.searchEndTime" @on-change="dateConfirm"></DatePicker>
			                    </FormItem>
			                </Col>
			            </Row>      
			        </FormItem>
				</Form>
			</div>
			<div slot="list_data">
				<Table border :columns="deliveryTable.deliveryColumns" :data="deliveryTable.deliveryData"></Table>
			</div>
		</wsSmPanel>

		<!-- 已完成列表 -->
		<wsSmPanel :page="completedTable.completedPage" @simple-query="query" @page-change="query" v-show="this.activeIndex == 4">
			<div slot="query_form">
				<Form :model="queryForm" :label-width="100" inline>
					<FormItem label="订单编号">
						<Input v-model="queryForm.sn" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="买家手机号">
						<Input v-model="queryForm.memberName" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="买家昵称">
						<Input v-model="queryForm.nickname" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="收货人姓名">
						<Input v-model="queryForm.consignee" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="收货人手机号">
						<Input v-model="queryForm.phone" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="时间区间">
						<Row>
			                <Col span="11">
			                    <FormItem>
			                        <DatePicker type="date" placeholder="查询开始时间" v-model="queryForm.searchStartTime" @on-change="dateConfirm"></DatePicker>
			                    </FormItem>
			                </Col>
			                <Col span="2" style="text-align: center">-</Col>
			                <Col span="11">
			                    <FormItem>
			                        <DatePicker type="date" placeholder="查询结束时间" v-model="queryForm.searchEndTime" @on-change="dateConfirm"></DatePicker>
			                    </FormItem>
			                </Col>
			            </Row>      
			        </FormItem>
				</Form>
			</div>
			<div slot="list_data">
				<Table border :columns="completedTable.completedColumns" :data="completedTable.completedData"></Table>
			</div>
		</wsSmPanel>

		<!-- 已关闭列表 -->
		<wsSmPanel :page="turnoffTable.turnoffPage" @simple-query="query" @page-change="query" v-show="this.activeIndex == 6">
			<div slot="query_form">
				<Form :model="queryForm" :label-width="100" inline>
					<FormItem label="订单编号">
						<Input v-model="queryForm.sn" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="买家手机号">
						<Input v-model="queryForm.memberName" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="买家昵称">
						<Input v-model="queryForm.nickname" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="收货人姓名">
						<Input v-model="queryForm.consignee" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="收货人手机号">
						<Input v-model="queryForm.phone" placeholder="请输入"></Input>
					</FormItem>
					<FormItem label="时间区间">
						<Row>
			                <Col span="11">
			                    <FormItem>
			                        <DatePicker type="date" placeholder="查询开始时间" v-model="queryForm.searchStartTime" @on-change="dateConfirm"></DatePicker>
			                    </FormItem>
			                </Col>
			                <Col span="2" style="text-align: center">-</Col>
			                <Col span="11">
			                    <FormItem>
			                        <DatePicker type="date" placeholder="查询结束时间" v-model="queryForm.searchEndTime" @on-change="dateConfirm"></DatePicker>
			                    </FormItem>
			                </Col>
			            </Row>      
			        </FormItem>
				</Form>
			</div>
			<div slot="list_data">
				<Table border :columns="turnoffTable.turnoffColumns" :data="turnoffTable.turnoffData"></Table>
			</div>
		</wsSmPanel>

		<!--发货弹框-->
		<wsModal v-model="shippingModal.show" ok-text="发货" title="发货" @on-ok="shippingModalOk" @on-cancel="shippingModalCancel">
		    <Form ref="shippingForm" :model="shippingModal.form" :rules="shippingModal.validate" :label-width="100">
				<FormItem label="物流公司" prop="expressId">
					<Select clearable v-model="shippingModal.form.expressId" filterable placeholder="请选择" class="ws-form-select" >
						<Option v-for="item in expressList" :value="item.value">{{item.label}}</Option>
					</Select>
				</FormItem>
				<FormItem label="运单号" prop="trackingNo">
					<Input v-model="shippingModal.form.trackingNo"></Input>
				</FormItem>
		    </Form>
		</wsModal>

		<!--订单修改弹框-->
		<wsModal v-model="updateModal.show" ok-text="修改订单支付金额" title="修改" @on-ok="updateModalOk" @on-cancel="updateModalCancel">
		    <Form ref="updateForm" :model="updateModal.form" :label-width="100">
				<!-- <FormItem label="总金额">
					<Input v-model="updateModal.form.totalAmount"></Input>
				</FormItem>
				<FormItem label="运费/￥">
					<Input v-model="updateModal.form.freight"></Input>
				</FormItem> -->
				<FormItem label="支付金额/￥" prop="payAmount">
					<Input v-model="updateModal.form.payAmount"></Input>
				</FormItem>
				<!-- <FormItem label="收货人">
					<Input v-model="updateModal.form.consignee"></Input>
				</FormItem>
				<FormItem label="收货人电话">
					<Input v-model="updateModal.form.phone"></Input>
				</FormItem>
				<FormItem label="快递详细地址">
					<Input v-model="updateModal.form.fullAddress" disabled="disabled"></Input>
				</FormItem> -->
				<!-- <FormItem label="快递地址">
		            <Cascader :data="areaData" :load-data="loadData" change-on-select v-model="ids"></Cascader>
		        </FormItem>
				<FormItem label="快递详细地址">
					<Input v-model="updateModal.form.address"></Input>
				</FormItem> -->
		    </Form>
		</wsModal>

		<!--物流跟踪弹框-->
		<wsModal v-model="logisticModal.show" title="物流信息" :whetherShowCancel="false" :whetherShowOk="false" 
		 @on-ok="logisticModalOk" @on-cancel="logisticModalCancel">
            <Row style="padding-bottom: 10px;">
				<Col span="24" class="layout-content-main" style= "font-size: 15px;">
					<Col span="12" >
						<Col span="8">
							快递公司:
						</Col>
						<Col>
							{{logisticModal.form.ShipperCode}}
						</Col> 
					</Col>
					<Col span="12">
						<Col span="6">
							运单号:
						</Col>
						<Col>
							{{logisticModal.form.LogisticCode}}
						</Col>	 
					</Col>
				</Col>
			</Row>
			<Row>
				<Col span="24" class="layout-content-main" style= "font-size: 15px;">
					<Steps :current="logisticModal.form.count" :status="logisticModal.form.state" direction="vertical">
				        <Step v-for="traces in logisticModal.form.traces" :title="traces.acceptStation" :content="traces.acceptTime"></Step>
					</Steps>
				</Col>
			</Row>
		</wsModal>
	</wsPage>
</template>

<script>
	export default {
		data() {
			return {
				type:0,
				AllNum:0,
				ToPayNum:0,
				ReceiveOrderNum:0,
				ShippingNum:0,
				DeliveryNum:0,
				CompletedNum:0,
				TurnoffNum:0,
				queryForm: {
					sn: '',
					searchStartTime: '',
					searchEndTime: '',
					memberName: '',
					nickname: '',
					consignee: '',
					phone: '',
					stat: {
						s0: 0,
						s1: 0,
						s2: 0,
						s3: 0,
						s4: 0,
						s6: 0,
						s7: 0
					},
				},
				//查询物流跟踪
				findLogistic: {
					orderId: ''
				},
				allTable: {
					allColumns: [{
                        type: 'selection',
                        width: 60,
                        align: 'center',
                        fixed: 'left'
                    },
					{
						title: '订单编号',
						key: 'sn',
	          			width: 220,
	          			align: 'center',
	          			fixed: 'left'
					},
					{
						title: '买家手机号',
						key: 'memberName',
	          			align: 'center'
					},
					{
						title: '买家昵称',
						key: 'nickname',
	          			align: 'center'
					},
					{
						title: '收货人',
						key: 'consignee',
	          			align: 'center'
					},
					{
						title: '收货人电话',
						key: 'phone',
	          			align: 'center'
					},
					{
						title: '交易状态',
						key: 'tradeStatus',
	          			align: 'center',
						render: (h, params) => {
							return h('span',{

							},this.checkStatus(params.row.tradeStatus))
						}
					},
					/*{
						title: '支付方式',
						key: 'payType',
	          			align: 'center',
						render: (h, params) => {
							return h('span',{

							},this.checkType(params.row.payType))
						}
					},*/
					{
						title: '创建日期',
						key: 'createDate',
	          			align: 'center'
					},
					{
						title: '操作',
						width: 200,
						fixed: 'right',
						align: 'center',
						render: (h, params) => {
							return h('div', [/*h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.updateModal.form.id = params.row.id;
										this.queryArea();
										this.queryOrder(params.row.id);
										this.updateModal.show = true;
									}
								}
							}, '编辑'),*/
							h('Button', {
								
								props: {
									
                                    type: 'text',
                                    size: 'small'
								},
								to: {name: '/orderDetail'},
								on: {
									click: () => {
										this.jumpDetail(params.row.id,params.row.refundId);
										router.push({ name: 'pathname'})
									}
								}
							}, '查看订单'),
							// h('Button', {
							// 	props: {
                            //         type: 'text',
                            //         size: 'small'
                            //     },
							// 	on: {
							// 		click: () => {
							// 			this.colseOrder(params.row.id);
							// 		}
							// 	}
							// }, '关闭')
							])
						}
					}],
					allData: [],
					allPage: {
						total: 0, //总条数
						pageNum: 1, //当前页
						pageSize: 10 //每页显示条数
					}
				},
				// 待付款列表
				toPayTable: {
					toPayColumns: [{
                        type: 'selection',
                        width: 60,
                        align: 'center',
                        fixed: 'left'
                    },
					{
						title: '订单编号',
						key: 'sn',
	          			width: 220,
	          			align: 'center',
	          			fixed: 'left'
					},
					{
						title: '买家手机号',
						key: 'memberName',
	          			align: 'center'
					},
					{
						title: '买家昵称',
						key: 'nickname',
	          			align: 'center'
					},
					// {
					// 	title: '交易状态',
					// 	key: 'tradeStatus',
	          		// 	align: 'center',
					// 	render: (h, params) => {
					// 		return h('span',{

					// 		},this.checkStatus(params.row.tradeStatus))
					// 	}
					// },
					/*{
						title: '支付方式',
						key: 'payType',
	          			align: 'center',
						render: (h, params) => {
							return h('span',{

							},this.checkType(params.row.payType))
						}
					},*/
					{
						title: '总金额/￥',
						key: 'totalAmount',
	          			align: 'center'
					},
					{
						title: '运费/￥',
						key: 'freight',
	          			align: 'center'
					},
					{
						title: '支付金额/￥',
						key: 'payAmount',
	          			align: 'center'
					},
					{
						title: '创建日期',
						key: 'createDate',
	          			align: 'center'
					},
					{
						title: '操作',
						width: 200,
						fixed: 'right',
						align: 'center',
						render: (h, params) => {
							return h('div', [h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.updateModal.form.id = params.row.id;
										this.queryOrder(params.row.id);
										this.queryArea();
										this.updateModal.show = true;
									}
								}
							}, '修改支付金额'),
							/*h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.deleteOrder(params.row.id);
									}
								}
							}, '删除'),*/h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.jumpDetail(params.row.id,params.row.refundId);
									}
								}
							}, '查看订单')])
						}
					}],
					toPayData: [],
					toPayPage: {
						total: 0, //总条数
						pageNum: 1, //当前页
						pageSize: 10 //每页显示条数
					}
				},
				// 待接单列表
				toReceiveOrderTable: {
					toReceiveColumns: [{
                        type: 'selection',
                        width: 60,
                        align: 'center',
                        fixed: 'left'
                    },
					{
						title: '订单编号',
						key: 'sn',
	          			width: 220,
	          			align: 'center',
	          			fixed: 'left'
					},
					{
						title: '买家手机号',
						key: 'memberName',
	          			align: 'center'
					},
					{
						title: '买家昵称',
						key: 'nickname',
	          			align: 'center'
					},
					{
					 	title: '交易状态',
					 	key: 'tradeStatus',
	          		 	align: 'center',
					 	render: (h, params) => {
					 		return h('span',{

					 		},this.checkStatus(params.row.tradeStatus))
					 	}
					},
					{
						title: '支付方式',
						key: 'payType',
	          			align: 'center',
						render: (h, params) => {
							return h('span',{

							},this.checkType(params.row.payType))
						}
					},
					{
						title: '总金额/￥',
						key: 'totalAmount',
	          			align: 'center'
					},
					{
						title: '运费/￥',
						key: 'freight',
	          			align: 'center'
					},
					{
						title: '支付金额/￥',
						key: 'payAmount',
	          			align: 'center'
					},
					{
						title: '创建日期',
						key: 'createDate',
	          			align: 'center'
					},
					{
						title: '操作',
						width: 200,
						fixed: 'right',
						align: 'center',
						render: (h, params) => {
							return h('div', [h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.receiveOrderTos(params.row.id);
									}
								}
							}, '确认接单'),
							/*h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.deleteOrder(params.row.id);
									}
								}
							}, '删除'),*/h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.jumpDetail(params.row.id,params.row.refundId);
									}
								}
							}, '查看订单')])
						}
					}],
					toReceiveOrderData: [],
					toReceiveOrderPage: {
						total: 0, //总条数
						pageNum: 1, //当前页
						pageSize: 10 //每页显示条数
					}
				},
				// 待发货列表
				shippingTable: {
					shippingColumns: [{
                        type: 'selection',
                        width: 60,
                        align: 'center',
                        fixed: 'left'
                    },
					{
						title: '订单编号',
						key: 'sn',
	          			width: 220,
	          			align: 'center',
	          			fixed: 'left'
					},
					{
						title: '买家手机号',
						key: 'memberName',
	          			align: 'center'
					},
					{
						title: '买家昵称',
						key: 'nickname',
	          			align: 'center'
					},
					// {
					// 	title: '交易状态',
					// 	key: 'tradeStatus',
	          		// 	align: 'center',
					// 	render: (h, params) => {
					// 		return h('span',{

					// 		},this.checkStatus(params.row.tradeStatus))
					// 	}
					// },
					{
						title: '收货人',
						key: 'consignee',
	          			align: 'center'
					},
					{
						title: '收货人电话',
						key: 'phone',
	          			align: 'center'
					},
					{
						title: '运费/￥',
						key: 'freight',
	          			align: 'center'
					},
					{
						title: '商品数量',
						key: 'quantity',
	          			align: 'center'
					},
					{
						title: '快递详细地址',
						key: 'fullAddress',
	          			align: 'center'
					},
					{
						title: '创建日期',
						key: 'createDate',
	          			align: 'center'
					},
					{
						title: '买家留言',
						key: 'memo',
	          			align: 'center'
                        
					},
					{
						title: '操作',
						width: 190,
						fixed: 'right',
						align: 'center',
						render: (h, params) => {
							let buttons_ = [];
							//审核第三方
							if(params.row.tradeStatus == 2) {
								buttons_.push(h('Button', {
									props: {
	                                    type: 'text',
	                                    size: 'small'
	                                },
									on: {
										click: () => {
											this.shippingModal.form.orderId = params.row.id;
											this.queryExpress();
										}
									}
								}, '发货'));
							}
							buttons_.push(h('Button', {
									props: {
	                                    type: 'text',
	                                    size: 'small'
	                                },
									on: {
										click: () => {
											this.jumpDetail(params.row.id,params.row.refundId);
										}
									}
							}, '查看订单'));
							return h('div', buttons_)
							/*,h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.deleteOrder(params.row.id);
									}
								}
							}, '删除')*/
						}
					}],
					shippingData: [],
					expressList: [],
					shippingPage: {
						total: 0, //总条数
						pageNum: 1, //当前页
						pageSize: 10 //每页显示条数
					}
				},
				// 已发货列表
				deliveryTable: {
					deliveryColumns: [{
                        type: 'selection',
                        width: 60,
                        align: 'center',
                        fixed: 'left'
                    },
					{
						title: '订单编号',
						key: 'sn',
	          			width: 220,
	          			align: 'center',
	          			fixed: 'left'
					},
					{
						title: '买家手机号',
						key: 'memberName',
	          			align: 'center'
					},
					{
						title: '买家昵称',
						key: 'nickname',
	          			align: 'center'
					},
					// {
					// 	title: '交易状态',
					// 	key: 'tradeStatus',
	          		// 	align: 'center',
					// 	render: (h, params) => {
					// 		return h('span',{

					// 		},this.checkStatus(params.row.tradeStatus))
					// 	}
					// },
					{
						title: '收货人',
						key: 'consignee',
	          			align: 'center'
					},
					{
						title: '收货人电话',
						key: 'phone',
	          			align: 'center'
					},
					{
						title: '运单号',
						key: 'trackingNo',
	          			align: 'center'
					},
					{
						title: '运费/￥',
						key: 'freight',
	          			align: 'center'
					},
					/*{
						title: '商品数量',
						key: 'quantity',
	          			align: 'center'
					},*/
					{
						title: '支付方式',
						key: 'payType',
	          			align: 'center',
						render: (h, params) => {
							return h('span',{

							},this.checkType(params.row.payType))
						}
					},
					{
						title: '创建日期',
						key: 'createDate',
						width: 160,
	          			align: 'center'
					},
					{
						title: '操作',
						width: 200,
						fixed: 'right',
						align: 'center',
						render: (h, params) => {
							return h('div', [h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.findLogistic.orderId = params.row.id;
										this.queryLogistic();
									}
								}
							}, '物流跟踪')/*,h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.deleteOrder(params.row.id);
									}
								}
							}, '删除')*/,h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.jumpDetail(params.row.id,params.row.refundId);
									}
								}
							}, '查看订单')])
						}
					}],
					deliveryData: [],
					expressList: [],
					deliveryPage: {
						total: 0, //总条数
						pageNum: 1, //当前页
						pageSize: 10 //每页显示条数
					}
				},
				// 已完成列表
				completedTable: {
					completedColumns: [{
                        type: 'selection',
                        width: 60,
                        align: 'center',
                        fixed: 'left'
                    },
					{
						title: '订单编号',
						key: 'sn',
	          			width: 220,
	          			align: 'center',
	          			fixed: 'left'
					},
					{
						title: '买家手机号',
						key: 'memberName',
	          			align: 'center'
					},
					{
						title: '买家昵称',
						key: 'nickname',
	          			align: 'center'
					},
					{
						title: '交易状态',
						key: 'tradeStatus',
	          			align: 'center',
						render: (h, params) => {
							return h('span',{

							},this.checkStatus(params.row.tradeStatus))
						}
					},
					{
						title: '总金额/￥',
						key: 'totalAmount',
	          			align: 'center'
					},
					{
						title: '支付金额/￥',
						key: 'payAmount',
	         			align: 'center'
					},
					{
						title: '创建日期',
						key: 'createDate',
	          			align: 'center'
					},
					{
						title: '操作',
						width: 200,
						fixed: 'right',
						align: 'center',
						render: (h, params) => {
							return h('div', [/*h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.updateModal.form.id = params.row.id;
										this.queryArea();
										this.queryOrder(params.row.id);
										this.updateModal.show = true;
									}
								}
							}, '编辑'),h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.deleteOrder(params.row.id);
									}
								}
							}, '删除'),*/h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.jumpDetail(params.row.id,params.row.refundId);
									}
								}
							}, '查看订单')])
						}
					}],
					completedData: [],
					completedPage: {
						total: 0, //总条数
						pageNum: 1, //当前页
						pageSize: 10 //每页显示条数
					}
				},
				// 已关闭列表
				turnoffTable: {
					turnoffColumns: [{
                        type: 'selection',
                        width: 60,
                        align: 'center',
                        fixed: 'left'
                    },
					{
						title: '订单编号',
						key: 'sn',
	            		width: 220,
	            		align: 'center',
	            		fixed: 'left'
					},
					{
						title: '买家手机号',
						key: 'memberName',
	          			align: 'center'
					},
					{
						title: '买家昵称',
						key: 'nickname',
	          			align: 'center'
					},
					{
						title: '交易状态',
						key: 'tradeStatus',
	          			align: 'center',
						render: (h, params) => {
							return h('span',{

							},this.checkStatus(params.row.tradeStatus))
						}
					},
					{
						title: '总金额/￥',
						key: 'totalAmount',
		          		align: 'center'
					},
					{
						title: '支付金额/￥',
						key: 'payAmount',
	          			align: 'center'
					},
					{
						title: '创建日期',
						key: 'createDate',
	          			align: 'center'
					},
					{
						title: '操作',
						width: 200,
						fixed: 'right',
						align: 'center',
						render: (h, params) => {
							return h('div', [/*h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.updateModal.form.id = params.row.id;
										this.queryArea();
										this.queryOrder(params.row.id);
										this.updateModal.show = true;
									}
								}
							}, '编辑'),h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.deleteOrder(params.row.id);
									}
								}
							}, '删除'),*/h('Button', {
								props: {
                                    type: 'text',
                                    size: 'small'
                                },
								on: {
									click: () => {
										this.jumpDetail(params.row.id,params.row.refundId);
									}
								}
							}, '查看订单')])
						}
					}],
					turnoffData: [],
					turnoffPage: {
						total: 0, //总条数
						pageNum: 1, //当前页
						pageSize: 10 //每页显示条数
					}
				},

				areaData: [],
				ids: [],
				activeIndex: 0,

				//发货弹框
				shippingModal: {
					show: false,
					form: {
						orderId: '',
						expressId: '',
						trackingNo: ''
					},
					validate: {
						expressName: [
	                        { required: true, message: '请填写快递公司名称', trigger: 'blur' }
	                    ],
						trackingNo: [
	                        { required: true, message: '请填写运单号', trigger: 'blur' }
	                    ],
					}
				},
				//订单修改弹框
				updateModal: {
					show: false,
					form: {
						id: '',
						consignee: '',
						phone: '',
						totalAmount: '',
						freight: '',
						payAmount: '',
						fullAddress: '',
						address: ''
					}
				},
				//物流跟踪
				logisticModal: {
					show: false,
					form: {
						ShipperCode:'',
						LogisticCode: '',
						traces: [],
						count: 0 ,
						state: null
					}
				}
			}
		},
		computed: {

		},
		mounted() {
			this.init();
		},
		methods: {
			order(t){
				let _this = this;
				_this.type = t;
				_this.query();
			},
			checkStatus(status){
				if(status == 1) return '等待买家付款';
				if(status == 2) return '买家已付款';
				if(status == 3) return '卖家已发货';
				if(status == 4) return '交易成功';
				if(status == 5) return '交易完成';
				if(status == 6) return '交易关闭';
				if(status == 7) return '卖家已接单';
			},

			checkType(type){
				if(type == 1) return '支付宝';
				if(type == 2) return '微信';
				if(type == 3) return '银联';
			},

			//查询开始时间段必填
			dateConfirm(){
				let searchStartTime = this.queryForm.searchStartTime;
				let searchEndTime = this.queryForm.searchEndTime;
				if (searchStartTime != null ||searchStartTime != '') {
					searchEndTime = new Date();
				} else if (searchEndTime != null || searchEndTime !='') {
					searchStartTime = searchEndTime;
				}
			},

			init() {
				this.query();
				this.initStat();
			},
			/**
			 * 表单查询
			 */
			query() {
				let pageSize;
				let pageNum;
				const _this = this;
				console
				if(_this.type == 'undefined' || _this.type == null){
					_this.type = 0;
				};
				if(_this.type == 0){
					pageSize = this.allTable.allPage.pageSize;
					pageNum = this.allTable.allPage.pageNum;
					this.toPayTable.toPayPage.pageNum = 1;
					this.toPayTable.toPayPage.pageSize = 10;
					this.shippingTable.shippingPage.pageNum = 1;
					this.shippingTable.shippingPage.pageSize = 10;
					this.deliveryTable.deliveryPage.pageNum = 1;
					this.deliveryTable.deliveryPage.pageSize = 10;
					this.completedTable.completedPage.pageNum = 1;
					this.completedTable.completedPage.pageSize = 10;
					this.turnoffTable.turnoffPage.pageNum = 1;
					this.turnoffTable.turnoffPage.pageSize = 10;
					this.activeIndex = 0;
				}
				if(_this.type == 1){
					pageSize = this.toPayTable.toPayPage.pageSize;
					pageNum = this.toPayTable.toPayPage.pageNum;
					this.allTable.allPage.pageNum = 1;
					this.allTable.allPage.pageSize = 10;
					this.shippingTable.shippingPage.pageNum = 1;
					this.shippingTable.shippingPage.pageSize = 10;
					this.deliveryTable.deliveryPage.pageNum = 1;
					this.deliveryTable.deliveryPage.pageSize = 10;
					this.completedTable.completedPage.pageNum = 1;
					this.completedTable.completedPage.pageSize = 10;
					this.turnoffTable.turnoffPage.pageNum = 1;
					this.turnoffTable.turnoffPage.pageSize = 10;
					this.activeIndex = 1;
				}
				if(_this.type == 2){
					pageSize = this.shippingTable.shippingPage.pageSize;
					pageNum = this.shippingTable.shippingPage.pageNum;
					this.allTable.allPage.pageNum = 1;
					this.allTable.allPage.pageSize = 10;
					this.toPayTable.toPayPage.pageNum = 1;
					this.toPayTable.toPayPage.pageSize = 10;
					this.deliveryTable.deliveryPage.pageNum = 1;
					this.deliveryTable.deliveryPage.pageSize = 10;
					this.completedTable.completedPage.pageNum = 1;
					this.completedTable.completedPage.pageSize = 10;
					this.turnoffTable.turnoffPage.pageNum = 1;
					this.turnoffTable.turnoffPage.pageSize = 10;
					this.activeIndex = 2;
				}
				if(_this.type == 3){
					pageSize = this.deliveryTable.deliveryPage.pageSize;
					pageNum = this.deliveryTable.deliveryPage.pageNum;
					this.allTable.allPage.pageNum = 1;
					this.allTable.allPage.pageSize = 10;
					this.toPayTable.toPayPage.pageNum = 1;
					this.toPayTable.toPayPage.pageSize = 10;
					this.shippingTable.shippingPage.pageNum = 1;
					this.shippingTable.shippingPage.pageSize = 10;
					this.completedTable.completedPage.pageNum = 1;
					this.completedTable.completedPage.pageSize = 10;
					this.turnoffTable.turnoffPage.pageNum = 1;
					this.turnoffTable.turnoffPage.pageSize = 10;
					this.activeIndex = 3;
				}
				if(_this.type == 4){
					pageSize = this.completedTable.completedPage.pageSize;
					pageNum = this.completedTable.completedPage.pageNum;
					this.allTable.allPage.pageNum = 1;
					this.allTable.allPage.pageSize = 10;
					this.toPayTable.toPayPage.pageNum = 1;
					this.toPayTable.toPayPage.pageSize = 10;
					this.shippingTable.shippingPage.pageNum = 1;
					this.shippingTable.shippingPage.pageSize = 10;
					this.deliveryTable.deliveryPage.pageNum = 1;
					this.deliveryTable.deliveryPage.pageSize = 10;
					this.turnoffTable.turnoffPage.pageNum = 1;
					this.turnoffTable.turnoffPage.pageSize = 10;
					this.activeIndex = 4;
				}
				if(_this.type == 6){
					pageSize = this.turnoffTable.turnoffPage.pageSize;
					pageNum = this.turnoffTable.turnoffPage.pageNum;
					this.allTable.allPage.pageNum = 1;
					this.allTable.allPage.pageSize = 10;
					this.toPayTable.toPayPage.pageNum = 1;
					this.toPayTable.toPayPage.pageSize = 10;
					this.shippingTable.shippingPage.pageNum = 1;
					this.shippingTable.shippingPage.pageSize = 10;
					this.deliveryTable.deliveryPage.pageNum = 1;
					this.deliveryTable.deliveryPage.pageSize = 10;
					this.completedTable.completedPage.pageNum = 1;
					this.completedTable.completedPage.pageSize = 10;
					this.activeIndex = 6;
				}
				if(_this.type == 7){
					pageSize = this.toReceiveOrderTable.toReceiveOrderPage.pageSize;
					pageNum = this.toReceiveOrderTable.toReceiveOrderPage.pageNum;
					this.allTable.allPage.pageNum = 1;
					this.allTable.allPage.pageSize = 10;
					this.toPayTable.toPayPage.pageNum = 1;
					this.toPayTable.toPayPage.pageSize = 10;
					this.shippingTable.shippingPage.pageNum = 1;
					this.shippingTable.shippingPage.pageSize = 10;
					this.deliveryTable.deliveryPage.pageNum = 1;
					this.deliveryTable.deliveryPage.pageSize = 10;
					this.completedTable.completedPage.pageNum = 1;
					this.completedTable.completedPage.pageSize = 10;
					this.activeIndex = 7;
				}
				this.axios.post('/ws/ms/orders?pageNum=' + pageNum + '&pageSize=' + pageSize + '&type=' + _this.type, this.queryForm).then(response => {
					var res = response.data;
					var resMeta = res.meta;
					if (0 == resMeta.code) {
						if(_this.type == 0){
							_this.buildPageData(res.data);
						}
						if(_this.type == 1){
							_this.buildPayPageData(res.data);
						}
						if(_this.type == 2){
							_this.buildShippingPageData(res.data);
						}
						if (_this.type == 3) {
							_this.buildDeliveryPageData(res.data);
						}
						if(_this.type == 4){
							_this.buildCompletedPageData(res.data);
						}
						if (_this.type == 6) {
							_this.buildTurnoffPageData(res.data);
						}
						if (_this.type == 7) {
							_this.buildReceivePageData(res.data);
						}
					} else {
						_this.$Message.warning(resMeta.message);
					}
				});
			},
			//初始化统计信息
			initStat() {
				const _this = this;
				this.axios.get("/ws/ms/orders/count").then(response => {
					var res = response.data;
					var resMeta = res.meta;
					if (0 == resMeta.code) {
					_this.buildStat(res.data);
					} else {
					_this.$Message.warning(resMeta.message);
					}
				});
			},
			/**
				 * 构建订单统计信息
				 * 1待付款 2 待发货 3已发货 4已完成  6已关闭 7待接单
				 * 
				 */
			buildStat(datas_) {
				let s0 = 0;
				let s1 = 0;
				let s2 = 0;
				let s3 = 0;
				let s4 = 0;
				let s6 = 0;
				let s7 = 0;
				for (let i = 0; i < datas_.length; i++) {
					let data_ = datas_[i];
					let sNum = parseInt(data_.count);
					s0 += sNum;
					if (data_.status == 1) {
						s1 += sNum;
					} else if (data_.status == 2) {
						s2 += sNum;
					} else if (data_.status == 3) {
						s3 += sNum;
					} else if (data_.status == 4) {
						s4 += sNum;
					} else if (data_.status == 6) {
						s6 += sNum;
					} else if (data_.status == 7) {
						s7 += sNum;
					}
				}
				this.queryForm.stat = {
					s0: s0,
					s1: s1,
					s2: s2,
					s3: s3,
					s4: s4,
					s6: s6,
					s7: s7
				};
			},
			/**
			 * 构建全部订单表格数据
			 */
			buildPageData(data_) {
				this.allTable.allData = data_.list;
				this.allTable.allPage.total = data_.total;
				this.AllNum = data_.total;
			},
			/**
			 * 构建待付款订单表格数据
			 */
			buildPayPageData(data_) {
				this.toPayTable.toPayData = data_.list;
				this.toPayTable.toPayPage.total = data_.total;
				this.ToPayNum = data_.total;
			},

			buildReceivePageData(data_) {
				this.toReceiveOrderTable.toReceiveOrderData = data_.list;
				this.toReceiveOrderTable.toReceiveOrderPage.total = data_.total;
				this.ReceiveOrderNum = data_.total;
			},
			/**
			 * 构建待发货订单表格数据
			 */
			buildShippingPageData(data_) {
				this.shippingTable.shippingData = data_.list;
				this.shippingTable.shippingPage.total = data_.total;
				this.ShippingNum = data_.total;
			},
			/**
			 * 构建已发货订单表格数据
			 */
			buildDeliveryPageData(data_) {
				this.deliveryTable.deliveryData = data_.list;
				this.deliveryTable.deliveryPage.total = data_.total;
				this.DeliveryNum = data_.total;
			},
			/**
			 * 构建已完成订单表格数据
			 */
			buildCompletedPageData(data_) {
				this.completedTable.completedData = data_.list;
				this.completedTable.completedPage.total = data_.total;
				this.CompletedNum = data_.total;
			},
			/**
			 * 构建已关闭订单表格数据
			 */
			buildTurnoffPageData(data_) {
				this.turnoffTable.turnoffData = data_.list;
				this.turnoffTable.turnoffPage.total = data_.total;
				this.TurnoffNum = data_.total;
			},
			/**
			 * 页面刷新
			 */
			refresh(){
				this.queryForm.sn = '';
				this.queryForm.searchStartTime = null;
				this.queryForm.searchEndTime = null;
				this.queryForm.consignee = '';
				this.queryForm.phone = '';
				this.queryForm.memberName = '';
				this.queryForm.nickname = '';
				this.type = 0;
				this.allTable.allPage.pageNum = 1;
				this.init();
			},
			/**
			 * 删除订单
			 */
			deleteOrder(id){
				const _this = this;
				this.axios.delete('/ws/ms/orders/' + id ).then(function(response) {
					let res = response.data;				
					if(0 === res.meta.code) {
						_this.$Message.success(res.meta.message);
						_this.query(_this.activeIndex);
					}else{
						let message_ = res.meta.message;
						_this.$Message.warning('删除失败:' + message_);
					}
				});
			},

			/**
			 * 查询指定订单
			 */
			queryOrder(id){
				const _this = this;
				this.axios.get('/ws/ms/orders/' + id ).then(function(response) {
					let res = response.data;				
					if(0 === res.meta.code) {
						_this.updateModal.form = res.data;
					}else{
						let message_ = res.meta.message;
						_this.$Message.warning('查询失败:' + message_);
					}
				});
			},

			/**
			 * 查询地区
			 */

	        loadData(item, callback){
	        	let parentId = item.value;
	        	const _this = this;
	        	item.loading = true;

        	 	_this.axios.get('/ws/ops/areas/children/' + parentId ).then(function(response) {
					let res = response.data;				
					if(0 === res.meta.code) {
						let areaList = _this.initAreaList(res.data);
						item.children = areaList;
						item.loading = false;
                		callback();
					}else{
						let message_ = res.meta.message;
						_this.$Message.warning('查询失败:' + message_);
					}
				});
	        },
	        queryArea(){
	        	const _this = this;
	        	this.axios.get('/ws/ops/areas/children/-1').then(function(response) {
					let res = response.data;				
					if(0 === res.meta.code) {
						let areaList = _this.initAreaList(res.data);
						_this.areaData = areaList;
					}else{
						let message_ = res.meta.message;
						_this.$Message.warning('查询失败:' + message_);
					}
				});
	        },
	        initAreaList(dataList){
	        	if (null != dataList) {
	        		dataList.forEach(function(value,index){
 						if (value.childrenNum > 0) {
 							value.loading = false;
 						}
				　　});
	        	}
	        	return dataList;
	        },
			/**
			 * 修改弹框取消操作
			 */
			updateModalCancel(){
				this.$refs['updateForm'].resetFields();
				this.updateModal.show = false;
			},
			/**
			 * 修改弹框确认操作
			 */
			updateModalOk(){
				const _this = this;
				this.axios.put('/ws/ms/orders', _this.updateModal.form).then(function(response) {
					let res = response.data;				
					if(0 === res.meta.code) {
						_this.$Message.success(res.meta.message);
					}else{
						let message_ = res.meta.message;
						_this.$Message.warning('修改失败:' + message_);
					}
					_this.$refs['updateForm'].resetFields();
					_this.updateModal.show = false;
					_this.init();
				});
			},

			/**
			 * 发货弹框确认操作
			 */
			shippingModalOk(){
				this.$refs['shippingForm'].validate((valid) => {
					if (valid) {
						this.shipping();
				    } else {
				        this.$Message.error('请完善发货信息!');
				    }
	            });
			},
			/**
			 * 发货弹框取消操作
			 */
			shippingModalCancel(){
				this.$refs['shippingForm'].resetFields();
				this.shippingModal.show = false;
			},

			shipping(){
				const _this = this;
				this.axios.put('/ws/ms/orders/shipping', _this.shippingModal.form).then(response => {
					let res = response.data;
					if(0 === res.meta.code) {
						_this.$Message.success('发货成功');
					} else {
						let message_ = res.meta.message;
						_this.$Message.warning('发货失败:' + message_);
					}
					_this.$refs['shippingForm'].resetFields();
					_this.shippingModal.show = false;
					_this.init();
				});
			},

			/**
			 * 查看详情
			 */
			jumpDetail(id,refundId){
				// this.$router.push('/orderDetail?id='+id);
				// this.$router.push({name:'/orderDetail?id='+id});
				if('' == refundId || null == refundId){
					refundId = "-1";
				}
				window.open('/orderDetail?id='+id+'&refundId='+refundId);
				// this.$router.push({name:'ms_orderDetail_detail',query:{id:id,refundId:refundId}});
			},

			/**
			 * 查询快递公司
			 */
			queryExpress(){
				const _this = this;
				this.axios.get('/ws/ops/expresss/findvalue').then(response => {
					let res = response.data;
					if(0 === res.meta.code) {
						_this.expressList = res.data;
						_this.shippingModal.show = true;
					} else {
						let message_ = res.meta.message;
						_this.$Message.warning('查询卡类型失败:' + message_);
					}
				});
			},
			/**
			 * 查询物流跟踪
			 */
			queryLogistic(){
				const _this = this;
    			this.axios.post('/ws/ms/orderShippings/condition' , this.findLogistic).then(response => {
					var res = response.data;
					var resMeta = res.meta;
					debugger
					if (0 == resMeta.code) {
						if(res.data[0].orderLogistic == null){
							_this.logisticModal.form.ShipperCode = res.data[0].ShipperCode;
							_this.logisticModal.form.LogisticCode = res.data[0].LogisticCode;
							_this.logisticModal.show = true;
							return;
						}
						_this.logisticModal.form = res.data[0].orderLogistic;
						if(res.data[0].orderLogistic.traces == null){
							_this.$Message.warning('查询物流失败');
							return;
						}
						_this.logisticModal.form.traces = _this.logisticModal.form.traces.reverse();
						_this.logisticModal.form.ShipperCode = res.data[0].expressName;
						_this.logisticModal.form.LogisticCode = res.data[0].trackingNo;
						_this.logisticModal.form.count = _this.logisticModal.form.traces.length - 1;
						_this.changeLogisticStatus( _this.logisticModal.form.state);
						_this.logisticModal.show = true;
					} else {
						_this.$Message.warning(resMeta.message);
					}
				});
			},
			changeLogisticStatus(State){
				if(State == '0' || State == '1' || State == '5'){
					this.logisticModal.form.state = 'process';
				}
				if(State == '3'){
					this.logisticModal.form.state = 'finish';
				}
				if(State == '4' || State == '2' || State == '6'){
					this.logisticModal.form.state = 'error';
				}
			},
			logisticModalOk(){

			},
			logisticModalCancel(){
				this.logisticModal.show = false;
				this.logisticModal.form.ShipperCode = '';
				this.logisticModal.form.LogisticCode = '';
				this.logisticModal.form.traces = [];
				this.logisticModal.form.count = 0;
			},
			/**
			 * 关闭订单
			 */
			colseOrder(id){
				const _this = this;
				this.axios.post('/ws/ms/orders/close/' + id ).then(function(response) {
					let res = response.data;				
					if(0 === res.meta.code) {
						_this.$Message.success(res.meta.message);
						_this.query(_this.activeIndex);
					}else{
						let message_ = res.meta.message;
						_this.$Message.warning('操作失败:' + message_);
					}
				});
			},

			/**
			 * 确认接单
			 */
			receiveOrderTos(id) {
				const _this = this;
				this.$confirm({
					title: "操作提示",
					width: 300,
					content: "你是否确认接单?",
					onOk: function() {
						_this.receiveOrder(id);
					}
				});
			},

			receiveOrder(id) {
				const _this = this;
				this.axios.put('/ws/ms/merchant/receive/order/' + id ).then(function(response) {
					let res = response.data;				
					if(0 === res.meta.code) {
						_this.$Message.success(res.meta.message);
						_this.query(_this.activeIndex);
						_this.initStat();
					}else{
						let message_ = res.meta.message;
						_this.$Message.warning('操作失败:' + message_);
					}
				});
			}

		}
	}
</script>

<style scoped>
.tab-demo {
  margin-bottom: 10px;
}
	.ws-form-select {
		width: 162px;
	}
	/*Button span {
		color: #f04844;
	}*/
</style>
